package br.senai.sc.test.util;

import org.jboss.seam.international.status.Messages;
import org.jboss.seam.international.status.builder.BundleKey;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.DependencyResolvers;
import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;

import br.senai.sc.controller.Parametro;
import br.senai.sc.controller.Qualidade;
import br.senai.sc.controller.business.AmostraBusiness;
import br.senai.sc.controller.business.AnexoBusiness;
import br.senai.sc.controller.business.BaciaHidrograficaBusiness;
import br.senai.sc.controller.business.CalculoColiformesBusiness;
import br.senai.sc.controller.business.CalculoDBOBusiness;
import br.senai.sc.controller.business.CalculoDiferencaTemperaturaBusiness;
import br.senai.sc.controller.business.CalculoFosforoBusiness;
import br.senai.sc.controller.business.CalculoNitrogenioBusiness;
import br.senai.sc.controller.business.CalculoODBusiness;
import br.senai.sc.controller.business.CalculoPhBusiness;
import br.senai.sc.controller.business.CalculoSolidosBusiness;
import br.senai.sc.controller.business.CalculoTurbidezBusiness;
import br.senai.sc.controller.business.CidadeBusiness;
import br.senai.sc.controller.business.CondicaoClimaticaBusiness;
import br.senai.sc.controller.business.CorpoHidricoBusiness;
import br.senai.sc.controller.business.FotoBusiness;
import br.senai.sc.controller.business.IQABusiness;
import br.senai.sc.controller.business.PontoColetaBusiness;
import br.senai.sc.controller.business.UsuarioBusiness;
import br.senai.sc.controller.crud.AmostraCRUD;
import br.senai.sc.controller.crud.AnexoCRUD;
import br.senai.sc.controller.crud.BaciaHidrograficaCRUD;
import br.senai.sc.controller.crud.CidadeCRUD;
import br.senai.sc.controller.crud.CondicaoClimaticaCRUD;
import br.senai.sc.controller.crud.CorpoHidricoCRUD;
import br.senai.sc.controller.crud.FotoCRUD;
import br.senai.sc.controller.crud.PontoColetaCRUD;
import br.senai.sc.controller.crud.RelatorioAmostra;
import br.senai.sc.controller.crud.UsuarioCRUD;
import br.senai.sc.controller.exception.BusinessException;
import br.senai.sc.controller.exception.HidroDataException;
import br.senai.sc.model.Amostra;
import br.senai.sc.model.Anexo;
import br.senai.sc.model.BaciaHidrografica;
import br.senai.sc.model.Cidade;
import br.senai.sc.model.CondicaoClimatica;
import br.senai.sc.model.CorpoHidrico;
import br.senai.sc.model.Estado;
import br.senai.sc.model.Foto;
import br.senai.sc.model.Permissao;
import br.senai.sc.model.PontoColeta;
import br.senai.sc.model.Usuario;
import br.senai.sc.util.AnexoUtils;
import br.senai.sc.util.ImageEditor;
import br.senai.sc.util.SystemConstants;

public final class Deploy {

	public static Archive<?> ceateTestArchive() {

		MavenDependencyResolver resolver = DependencyResolvers.use(
				MavenDependencyResolver.class).loadMetadataFromPom("pom.xml");

		return ShrinkWrap
				.create(WebArchive.class, "hidroDataTest.war")
				.addClasses(
						// entidades
						PontoColeta.class,
						Cidade.class,
						Estado.class,
						Amostra.class,
						CorpoHidrico.class,
						BaciaHidrografica.class,
						CondicaoClimatica.class,
						Qualidade.class,
						Foto.class,
						Anexo.class,
						Amostra.class,
						Qualidade.class,
						Usuario.class,
						Parametro.class,

						// utils
						AnexoUtils.class,
						ImageEditor.class,
						TestUtils.class,
						SystemConstants.class,

						// exceções
						HidroDataException.class,
						BusinessException.class,

						// cruds
						AmostraCRUD.class,
						AnexoCRUD.class,
						BaciaHidrograficaCRUD.class,
						CidadeCRUD.class,
						CondicaoClimaticaCRUD.class,
						CorpoHidricoCRUD.class,
						FotoCRUD.class,
						PontoColetaCRUD.class,
						UsuarioCRUD.class,
						RelatorioAmostra.class,

						// business
						AmostraBusiness.class, AnexoBusiness.class,
						BaciaHidrograficaBusiness.class,
						CalculoColiformesBusiness.class,
						CalculoDBOBusiness.class,
						CalculoDiferencaTemperaturaBusiness.class,
						CalculoFosforoBusiness.class,
						CalculoNitrogenioBusiness.class,
						CalculoODBusiness.class, CalculoPhBusiness.class,
						CalculoSolidosBusiness.class,
						CalculoTurbidezBusiness.class, CidadeBusiness.class,
						CondicaoClimaticaBusiness.class,
						CorpoHidricoBusiness.class, FotoBusiness.class,
						IQABusiness.class, PontoColetaBusiness.class,
						UsuarioBusiness.class,

						BundleKey.class, Messages.class, Permissao.class)
				.addAsLibraries(
						resolver.artifact(
								"org.jboss.seam.international:seam-international")
								.resolveAsFiles())
				.addAsLibraries(
						resolver.artifact("joda-time:joda-time")
								.resolveAsFiles())
				.addAsResource("test-persistence.xml",
						"META-INF/persistence.xml")
				.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
	}
}
